//===============================================================================
// Microsoft Architecture Strategy Team
// LitwareHR - SaaS Sample Application
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================


//===============================================================================
// Microsoft Architecture Strategy Team
// LitwareHR - S+S Sample Application
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using Microsoft.Practices.SmartClient.DisconnectedAgent;
using Shp.Runtime.Contract;
using System;
using System.Collections.Generic;
using LitwareHR.Infrastructure.Interface;

namespace LitwareHR.PublicApp.WinUX.DSA.UnSecure.DataModelService
{
	// Generated code for the web service.
	// Use this proxy to make requests to the service when working in an application that is occasionally connected
    public class Callback : CallbackBase
    {
        #region Event Handlers

        #region GetInstanceList

        public static event EventHandler<InstanceListEventArgs> GetInstanceListReturn;
        public static event EventHandler<EventArgs<Exception>>  GetInstanceListException;

        #endregion GetInstanceList

        #region GetViewDefFields

        public static event EventHandler<ViewDefListEventArgs> GetViewDefFieldsReturn;
        public static event EventHandler<EventArgs<Exception>> GetViewDefFieldsException;

        #endregion GetViewDefFields

        #region GetViewDefFieldsById

        public static event EventHandler<EventArgs<StringPair[]>> GetViewDefFieldsByIdReturn;
        public static event EventHandler<EventArgs<Exception>> GetViewDefFieldsByIdException;

        #endregion GetViewDefFieldsById

        #region GetEntityDefFields

        public static event EventHandler<EventArgs<EntityField[]>> GetEntityDefFieldsReturn;
        public static event EventHandler<EventArgs<Exception>> GetEntityDefFieldsException;

        #endregion GetEntityDefFields

        #region GetEntityDefList

        public static event EventHandler<EventArgs<Dictionary<Guid, string>>> GetEntityDefListReturn;
        public static event EventHandler<EventArgs<Exception>> GetEntityDefListException;

        #endregion GetEntityDefList

        #region GetViewDefList

        public static event EventHandler<EventArgs<Dictionary<Guid, string>>> GetViewDefListReturn;
        public static event EventHandler<EventArgs<Exception>> GetViewDefListException;

        #endregion GetViewDefList

        #region GetTypeList

        public static event EventHandler<EventArgs<GuidStringPair[]>> GetTypeListReturn;
        public static event EventHandler<EventArgs<Exception>> GetTypeListException;

        #endregion GetTypeList

        #endregion
        
        #region GetInstanceList

        public override void OnGetInstanceListReturn(Request request, object[] parameters, StringPair[][] returnValue)
		{
            if (GetInstanceListReturn != null)
            {
                GetInstanceListReturn(this, new InstanceListEventArgs(parameters[1].ToString() ,returnValue));
            }
		}

		public override OnExceptionAction OnGetInstanceListException(Request request, Exception ex)
		{
            if (GetInstanceListException != null)
            {
                GetInstanceListException(this, new EventArgs<Exception>(ex));
            }
            return OnExceptionAction.Retry;
		}
		
		#endregion GetInstanceList
		
		#region GetViewDefFields
	
		public override void OnGetViewDefFieldsReturn(Request request, object[] parameters, StringPair[] returnValue)
		{
            if (GetViewDefFieldsReturn != null)
            {
                GetViewDefFieldsReturn(this, new ViewDefListEventArgs(parameters[1].ToString(),returnValue));
            }
		}

		public override OnExceptionAction OnGetViewDefFieldsException(Request request, Exception ex)
		{
            if (GetViewDefFieldsException != null)
            {
                GetViewDefFieldsException(this, new EventArgs<Exception>(ex));
            }
            return OnExceptionAction.Retry;
		}
		
		#endregion GetViewDefFields
		
		#region GetViewDefFieldsById
	
		public override void OnGetViewDefFieldsByIdReturn(Request request, object[] parameters, StringPair[] returnValue)
		{
            if (GetViewDefFieldsByIdReturn != null)
            {
                GetViewDefFieldsByIdReturn(this, new EventArgs<StringPair[]>(returnValue));
            }
		}

		public override OnExceptionAction OnGetViewDefFieldsByIdException(Request request, Exception ex)
		{
            if (GetViewDefFieldsByIdException != null)
            {
                GetViewDefFieldsByIdException(this, new EventArgs<Exception>(ex));
            }
            return OnExceptionAction.Retry;
		}
		
		#endregion GetViewDefFieldsById
		
		#region GetEntityDefFields
	
		public override void OnGetEntityDefFieldsReturn(Request request, object[] parameters, EntityField[] returnValue)
		{
            if (GetEntityDefFieldsReturn != null)
            {
                GetEntityDefFieldsReturn(this, new EventArgs<EntityField[]>(returnValue));
            }
		}

		public override OnExceptionAction OnGetEntityDefFieldsException(Request request, Exception ex)
		{
            if (GetEntityDefFieldsException != null)
            {
                GetEntityDefFieldsException(this, new EventArgs<Exception>(ex));
            }
            return OnExceptionAction.Retry;
		}
		
		#endregion GetEntityDefFields
		
		#region GetEntityDefList
	
		public override void OnGetEntityDefListReturn(Request request, object[] parameters, Dictionary<Guid, string> returnValue)
		{
            if (GetEntityDefListReturn != null)
            {
                GetEntityDefListReturn(this, new EventArgs<Dictionary<Guid, string>>(returnValue));
            }
		}

		public override OnExceptionAction OnGetEntityDefListException(Request request, Exception ex)
		{
            if (GetEntityDefListException != null)
            {
                GetEntityDefListException(this, new EventArgs<Exception>(ex));
            }
            return OnExceptionAction.Retry;
		}
		
		#endregion GetEntityDefList
		
		#region GetViewDefList

        public override void OnGetViewDefListReturn(Request request, object[] parameters, Dictionary<Guid, string> returnValue)
		{
            if (GetViewDefListReturn != null)
            {
                GetViewDefListReturn(this, new EventArgs<Dictionary<Guid, string>>(returnValue));
            }
		}

		public override OnExceptionAction OnGetViewDefListException(Request request, Exception ex)
		{
            if (GetViewDefListException != null)
            {
                GetViewDefListException(this, new EventArgs<Exception>(ex));
            }
            return OnExceptionAction.Retry;
		}
		
		#endregion GetViewDefList
		
		#region GetTypeList
	
		public override void OnGetTypeListReturn(Request request, object[] parameters, GuidStringPair[] returnValue)
		{
            if (GetTypeListReturn != null)
            {
                GetTypeListReturn(this, new EventArgs<GuidStringPair[]>(returnValue));
            }
		}

		public override OnExceptionAction OnGetTypeListException(Request request, Exception ex)
		{
            if (GetTypeListException != null)
            {
                GetTypeListException(this, new EventArgs<Exception>(ex));
            }
            return OnExceptionAction.Retry;
		}
		
		#endregion GetTypeList
		
	}

    public class ViewDefListEventArgs : EventArgs
    {
        string viewDefName = null;

        public string ViewDefName
        {
            get { return viewDefName; }            
        }

        StringPair[] viewDef = null;

        public StringPair[] ViewDef
        {
            get { return viewDef; }            
        }

        public ViewDefListEventArgs(string viewDefName, StringPair[] viewDef)
        {
            this.viewDefName = viewDefName;
            this.viewDef = viewDef; 
        }
    }

    public class InstanceListEventArgs : EventArgs
    {
        string entityDefName = null;

        public string EntityDefName
        {
            get { return entityDefName; }
        }

        StringPair[][] entityInstanceDef = null;

        public StringPair[][] EntityInstanceDef
        {
            get { return entityInstanceDef; }
        }

        public InstanceListEventArgs(string entityDefName, StringPair[][] entityInstanceDef)
        {
            this.entityDefName = entityDefName;
            this.entityInstanceDef = entityInstanceDef;
        }
    }

}
